package com.qf.mrboot2.controller;

import com.qf.mrboot2.entity.Subject;
import com.qf.mrboot2.result.ResponseData;
import com.qf.mrboot2.service.SubjectService;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * (Subject)表控制层
 *
 * @author makejava
 * @since 2021-05-28 11:08:37
 */
@RestController
@RequestMapping("subject")
public class SubjectController {
    /**
     * 服务对象
     */
    @Resource
    private SubjectService subjectService;

    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @GetMapping("selectOne")
    public Subject selectOne(Integer id) {
        return this.subjectService.queryById(id);
    }

    //http://localhost:8080/subject/queryByTitle/{title}---get
    /**
     *
     * 根据名称查找项目
     * @param title 项目名称
     * @return 项目信息
     * */
    @ApiOperation(value = "queryByTitle",notes = "根据名称查找项目")
    @ApiImplicitParam(name = "title",value = "项目的名称")
    @GetMapping("queryByTitle/{title}")
    public ResponseData queryByTitle(@PathVariable String title){
        return subjectService.queryByTitle(title);
    }

    @ApiOperation(value = "queryHot",notes = "查询前三个")
    @GetMapping("queryHot")
    public ResponseData queryHot(){
        return subjectService.queryHot();
    }

}
